<!doctype html>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>全国中小企业股转系统</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/linkage.js"></script>
<script type="text/javascript" src="js/all.js"></script>
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon">
</head>

<body>
	<div class="zxcf_top_wper">
		<div class="zxcf_top px1000 clearfix">
			<div class="zxcf_top_r fr">
				<a href="tranrisk.html">风险提示</a> <span>|</span> <a
					href="problem.html">法律法规</a>
			</div>
		</div>
	</div>
	<!-- end top -->
	<div class="zxcf_nav_wper">
		<div class="zxcf_nav clearfix px1000">
			<div class="zxcf_nav_l fl">
				<img src="images/zxcf_logo.png" alt="">
			</div>
		</div>
	</div>
	<!-- end  -->
	<div class="reg_con_wper">
		<div class="reg_con px1000">
			<div class="reg_box clearfix">
				<div class="reg_box_l fl">
					<img src="
		   	   	  images/reg_pic01.png" alt="">
				</div>
				<div class="reg_box_r fl">
					<h2 class="lg_sec_tit clearfix zxcf_nav_zc">
						<span class="fl">申请账户</span> <em class="fr"><a
							href="login.html">立即登录</a></em>
					</h2>
					<form>
						<p class="mt20">
							<input type="text" id="userName" name="userName" required
								oninput="validUserName()" placeholder="姓名"
								class="lg_input01 lg_input" /> <span id="nameError"
								style="color: #f00;"></span>
						</p>
						<p class="mt20">
							<input type="text" id="idCard" name="idCard" required
								onblur="isnotIdcard(value,'idError')" placeholder="身份证号"
								class="lg_input06 lg_input" /> <span id="idError"
								style="color: #f00;"></span>
						</p>
						<p class="mt20">
							<input type="text" id="phone" name="phone" required
								onblur="isnotPhone(value,'phoneError')" id="phone"
								placeholder="手机号" class="lg_input03 lg_input" /> <span
								id="phoneError" style="color: #f00;"></span>
						</p>
						<p class="mt20">
							<input type="passWord" id="passWord" name="passWord" required
								placeholder="密码" oninput="validPsd()"
								class="lg_input02 lg_input" /> <span id="psdError"
								style="color: #f00;"></span>
						</p>
						<p class="mt20">
							<input type="passWord" id="psdAgain" required placeholder="密码确认"
								class="lg_input02 lg_input" oninput="validPsdAgain()" /> <span
								id="psdAgainError" style="color: #f00;"></span>
						</p>


						<p class="pt10">
							<!--<a href="#">使用条款</a>&nbsp;&nbsp;<a href="#">隐私条款</a>-->
						</p>
						<p class="mt20">
							<button type="button" onclick="validParam()" class="lg_btn commonLink">提交审核</button>
							<!--<a href="#" onclick="registerData()" class="lg_btn">立即注册</a>-->
						</p>
					</form>
				</div>
			</div>
		</div>
	</div>
	<!-- 弹窗 -->
	<div id="errorMsgModal" class="modal">
		<div class="modal-content" style="width: 300px;">
			<div style="height: 60px;">
				<span style="font-size: 16px;" id="errorMsg"></span>
			</div>
			<div class="modal-footer">
				<div style="width: 100%;">
					<button type="button" class="commonLink"
						style="margin-right: 10px; width: 70px; height: 30px; font-size: 15px"
						onclick="closeWindow('errorMsgModal')">确定</button>
				</div>
			</div>
		</div>
	</div>
</body>
<script>
	document.onkeydown = function(e) {
		var ev = (typeof event != "undefined") ? window.event : e;
		if (ev.keyCode === 13) {
			validParam();
		}
	}
	//校验用户名
	function validUserName() {
		document.getElementById("nameError").innerText = "";
		var value = document.getElementById("userName").value;
		if (!userNameValidator.test(value)) {
			document.getElementById("nameError").innerText = "请输入合法的姓名。由中文字符、英文字母、中划线（-）、下划线（_）、点（·）组成，长度是1到255位。";
			return false;
		}
	}
	//校验密码
	function validPsd() {
		document.getElementById("psdError").innerText = "";
		var value = document.getElementById("passWord").value;
		if (!passwordValidator.test(value)) {
			document.getElementById("psdError").innerText = "用户密码以字母开头，长度在6-18之间，只能包含英文字母、数字和下划线。";
			return false;
		}
	}
	//再次输入密码
	function validPsdAgain() {
		document.getElementById("psdAgainError").innerText = "";
		var value = document.getElementById("psdAgain").value;
		var psd = document.getElementById("passWord").value;
		if (value !== psd) {
			document.getElementById("psdAgainError").innerText = "两次输入密码不一致。";
			return false;
		}
	}
	//注册提交时校验参数
	function validParam() {
		var name = document.getElementById("userName").value;
		if (name === "") {
			document.getElementById("errorMsg").innerHTML = "姓名不能为空。";
			openWindow("errorMsgModal");
			return;
		}
		var idCard = document.getElementById("idCard").value;
		if (idCard === "") {
			document.getElementById("errorMsg").innerHTML = "身份证号不能为空。";
			openWindow("errorMsgModal");
			return;
		}
		var phone = document.getElementById("phone").value;
		if (phone === "") {
			document.getElementById("errorMsg").innerHTML = "手机号不能为空。";
			openWindow("errorMsgModal");
			return;
		}
		var passWord = document.getElementById("passWord").value;
		if (passWord === "") {
			document.getElementById("errorMsg").innerHTML = "密码不能为空。";
			openWindow("errorMsgModal");
			return;
		}
		var nameError = document.getElementById("nameError").innerHTML;
		if (nameError) {
			document.getElementById("errorMsg").innerHTML = "姓名输入不合法，请确认。";
			openWindow("errorMsgModal");
			return;
		}
		var idCardError = document.getElementById("idError").innerHTML;
		if (idCardError) {
			document.getElementById("errorMsg").innerHTML = "身份证号输入不合法，请确认。";
			openWindow("errorMsgModal");
			return;
		}
		var phoneError = document.getElementById("phoneError").innerHTML;
		if (phoneError) {
			document.getElementById("errorMsg").innerHTML = "手机号输入不合法，请确认。";
			openWindow("errorMsgModal");
			return;
		}
		var psdError = document.getElementById("psdError").innerHTML;
		if (psdError) {
			document.getElementById("errorMsg").innerHTML = "密码输入不合法，请确认。";
			openWindow("errorMsgModal");
			return;
		}
		var psdAgainError = document.getElementById("psdError").innerHTML;
		if (psdAgainError) {
			document.getElementById("errorMsg").innerHTML = "两次密码输入不一致，请确认。";
			openWindow("errorMsgModal");
			return;
		}
		registerData();
	}

	// 注册
	function registerData() {
		var options = {
			"phone" : document.getElementById("phone").value, //手机号
			"passWord" : document.getElementById("passWord").value, //密码
			"userName" : document.getElementById("userName").value, //用户名
			"idCard" : document.getElementById("idCard").value //身份证号
		};
		$.ajax({
			type : "POST",
			url : "/ThreeNewBoard/register",
			data : JSON.stringify(options),
			crossDomain : true,
			async : true,
			contentType : "application/json",
			dataType : "json",
			success : function(result) {
				var data = result.data;
				if (data.isRegister) {
					alert("您的账户正在审核！\n审核结果会发送到您申请账户使用的的手机号，请耐心等待！");
					location.href = "login.html";
				} else {
					alert(JSON.stringify(data.promptMessage).replace("\"", "")
							.replace("\"", ""));
				}
			}
		});
	}
</script>

</html>